from tkinter import *

root = Tk()
def callback(event):
    print("鼠标位置:",event.x,event.y)
    var.set("鼠标放这里吧~")
    location = ('鼠标位置:',event.x,event.y)
    var2.set(location)
    print(var2.get())

def callback2(event):
    print("鼠标位置:",event.x,event.y)
    var.set("放稳了，不要划出去了~")
    location = ['鼠标位置:',event.x,event.y]
    var2.set(location)
    print(var2.get())

def callback3(event):
    print("鼠标位置:",event.x,event.y)
    var.set("鼠标放这里吧~")
    var2.set("放其他地方去，我是用来显示坐标的~")
var = Variable()
var2 = StringVar()
var.set("鼠标放这试试")
var2.set("鼠标位置:未知")
frame = Frame(root,width = 300,height = 300,bg = "green")
frame.bind("<Motion>",callback)
frame.pack()
label = Label(root,textvariable = var,bg = "red",width = 42)
label.bind("<Motion>",callback2)
label.pack()
label_location = Label(root,textvariable = var2,bg = "yellow",width = 42)
label_location.bind("<Motion>",callback3)
label_location.pack()
mainloop()
